/**
* ...
* @author Default
* @version 0.1
*/

package {

	import flash.events.*;
	import org.anivision.document.DocumentManager;
	import org.anivision.forms.MainForm;
	import org.anivision.*;
	import org.aswing.*;

	public class App {
		
		private static var _app:AppMain;
		private static var _a001:JToolBar		= new JToolBar();
		private static var _a002:JTabbedPane	= new JTabbedPane();
		private static var _a003:JTextArea		= new JTextArea();
		private static var _a004:JWindow		= new JWindow();
		private static var _a005:JSpacer		= new JSpacer();
		
		public static function init(app:AppMain):void {
			if (App._app == null)
				App._app = app;
				
		}
		
		public static function setOpenDocumentMenuItem(name:String, onClick:Function):JMenuItem {
			var mitem:JMenuItem = new JMenuItem();
			mitem.setName(name);
			mitem.setText(name);
			_app.mainform.get_file_open().append(mitem);
			
			mitem.addEventListener(MouseEvent.CLICK, onClick);
			
			return mitem;
		}
				
		public static function setNewDocumentMenuItem(name:String, onClick:Function):JMenuItem {
			var mitem:JMenuItem = new JMenuItem();
			mitem.setName(name);
			mitem.setText(name);
			_app.mainform.get_file_new().append(mitem);
			
			mitem.addEventListener(MouseEvent.CLICK, onClick);
			
			return mitem;
		}
		
		public static function openFile(path:String, onComplete:Function, onProgress:Function): void {
			_app.openFile(path, onComplete, onProgress);
		}
		
		public static function get documentManager(): DocumentManager {
			return _app.documentManager;
		}

		public static function get mainForm():MainForm {
			return _app.mainform;
		}
		
		public static function get AppPath():String {
			return _app.appPath;
		}
		
		public static function addToolBar(toolbar:JToolBar):void {
			App.mainForm.get_tools().append(toolbar);
		}
	}
}